﻿namespace WMS6.Web.Inventory
{
    using System;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using WMS6.Web;
    using WMS6.Web.InventoryMgtServiceRef;
    using WMS6.Web.UserControls;

    public class InvTrans : BasePage
    {
        protected Button btnGoBack;
        protected HtmlForm F5021;
        protected HiddenField hdnExpiryDate;
        protected HiddenField hdnLot1;
        protected HiddenField hdnLot10;
        protected HiddenField hdnLot2;
        protected HiddenField hdnLot3;
        protected HiddenField hdnLot4;
        protected HiddenField hdnLot5;
        protected HiddenField hdnLot6;
        protected HiddenField hdnLot7;
        protected HiddenField hdnLot8;
        protected HiddenField hdnLot9;
        protected HiddenField hdnProductDate;
        protected HtmlInputHidden hdnType;
        protected HtmlHead Head1;
        protected Label lblCreatedDate;
        protected Label lblDesc;
        protected Label lblDocID;
        protected Label lblDocLineID;
        protected Label lblExternalLot;
        protected Label lblFromLoc;
        protected Label lblFromLpnID;
        protected Label lblHoldCode;
        protected Label lblMsg;
        protected Label lblOwner;
        protected Label lblPackID;
        protected Label lblQty;
        protected Label lblReceiptID;
        protected Label lblSkuID;
        protected Label lblSourceTransType;
        protected Label lblToLoc;
        protected Label lblToLpnID;
        protected Label lblTransID;
        protected Label lblTransType;
        protected Label lblUomID;
        protected Label lblUpdateBy;
        protected Label lblUpdateDate;
        protected LotAtrributeCtrl LotAtrributeCtrl1;
        protected HtmlLink mycss;
        protected Label one1;
        protected Label one2;
        protected ScriptManager ScriptManager1;
        protected TextBox txtCreatedDate;
        protected TextBox txtDesc;
        protected TextBox txtDocID;
        protected TextBox txtDocLineID;
        protected TextBox txtExternalLot;
        protected TextBox txtFromLoc;
        protected TextBox txtFromLpnID;
        protected TextBox txtHoldCode;
        protected TextBox txtOwnerID;
        protected TextBox txtPackID;
        protected TextBox txtQty;
        protected TextBox txtSkuID;
        protected TextBox txtSourceTransType;
        protected TextBox txtToLoc;
        protected TextBox txtToLpnID;
        protected TextBox txtTransID;
        protected TextBox txtTransType;
        protected TextBox txtUomID;
        protected TextBox txtUpdateBy;
        protected TextBox txtUpdateDate;

        protected void btnGoBack_Click(object sender, EventArgs e)
        {
            base.Response.Redirect("InvTransList.aspx?from=edit", false);
        }

        private void LoadData()
        {
            if (!string.IsNullOrEmpty(base.Request.QueryString["ID"]))
            {
                InvTransInfo invTrans = InventoryMgtServiceClientProxy.GetInstance().GetInvTransByID(base.Request.QueryString["ID"]);
                this.SetInvTransInfo2Form(invTrans);
                this.LotAtrributeCtrl1.LoadData(this.txtSkuID.Text.Trim(), this.txtOwnerID.Text.Trim(), this.LotAtrributeCtrl1.ClientID.ToString(), false, 4);
                this.hdnType.Value = "Edit";
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                base.InitPage(this.Page);
                this.LoadData();
            }
        }

        private void SetInvTransInfo2Form(InvTransInfo invTrans)
        {
            this.txtCreatedDate.Text = base.GetPreferenceShortDate(invTrans.TransDate);
            this.txtDesc.Text = invTrans.Descr;
            this.txtExternalLot.Text = invTrans.ExternalLot;
            this.txtFromLoc.Text = invTrans.FromLoc;
            this.txtFromLpnID.Text = invTrans.FromLpnID;
            this.txtHoldCode.Text = invTrans.HoldCode;
            this.hdnLot1.Value = invTrans.LotAttr01;
            this.hdnLot2.Value = invTrans.LotAttr02;
            this.hdnLot3.Value = invTrans.LotAttr03;
            this.hdnLot4.Value = invTrans.LotAttr04;
            this.hdnLot5.Value = invTrans.LotAttr05;
            this.hdnLot6.Value = invTrans.LotAttr06;
            this.hdnLot7.Value = invTrans.LotAttr07;
            this.hdnLot8.Value = invTrans.LotAttr08;
            this.hdnLot9.Value = invTrans.LotAttr09;
            this.hdnLot10.Value = invTrans.LotAttr10;
            this.hdnExpiryDate.Value = base.GetPreferenceShortDate(invTrans.ExpiryDate);
            this.hdnProductDate.Value = base.GetPreferenceShortDate(invTrans.ProduceDate);
            this.txtOwnerID.Text = invTrans.OwnerID;
            this.txtPackID.Text = invTrans.PackID;
            this.txtQty.Text = base.GetPreferenceDigit(invTrans.Qty);
            this.txtSkuID.Text = invTrans.SkuID;
            this.txtSourceTransType.Text = invTrans.SourceTransTypeD;
            this.txtToLoc.Text = invTrans.ToLoc;
            this.txtToLpnID.Text = invTrans.ToLpnID;
            this.txtTransID.Text = invTrans.TransID;
            this.txtTransType.Text = invTrans.TransTypeD;
            this.txtUomID.Text = invTrans.UomID;
            this.txtUpdateBy.Text = invTrans.UpdatedBy;
            this.txtUpdateDate.Text = base.GetPreferenceShortDate(invTrans.UpdatedDate);
            this.txtDocID.Text = invTrans.DocID;
            this.txtDocLineID.Text = invTrans.DocLineID.ToString();
        }
    }
}

